-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I want to build a hierarchy from a one-dimensional array and can (almost) do so with a more or less hardcoded code. How can I make the code dynamic?
Perhaps with while(isset($array[$key])) { ... }?
Or, with an extra function? Like this: $out = my_extra_traverse_function($array,$key);
function array_traverse($array…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Lets say I have a simple 1D array with 10-20 entries. Some will be duplicate, How would I find out which entry is used the most? like..
$code = Array("test" , "cat" , "test" , "this", "that", "then");
How would I show "test" as the most used entry?
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
How do I identify an item in a hash array if the key of the array is only known within a variable? For example:
var key = "myKey";
var array = {myKey: 1, anotherKey: 2};
alert(array.key);
Also, how would I assign a value to that key, having identified it with the variable?
This is, of course,…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hi all, I have an array, which I'd like to search for a value in and retreive the array key if it exists, but not sure how to even go about doing that. Here's my array:
Array
(
[hours] => Array
(
[0] => 5
[1] => 5
[2] => 6
[3]…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I have some data, yes, data. This data came from a MySQL query and it will always contain 4 items, always. I want to cache that data in an array table for use later within a web page but I want to keep the keys from the query and separate out each grouping within a multidimensional array. However…
>>> More